package com.cn.web.controller.Report;

import com.alibaba.fastjson2.JSONObject;
import com.cn.bean.vo.Report.ComponentSingleReport;
import com.cn.bean.vo.Report.ItemReport;
import com.cn.service.server.Report.ComponentSingleReportService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@Slf4j
@Transactional
public class ComponentSingleReportController {
    @Autowired
    private ComponentSingleReportService componentSingleReportService;


    @RequestMapping("/select/ComponentSingleReport")
    @ResponseBody
    public List<ComponentSingleReport> selectItemReport(@RequestBody JSONObject jsonObject) {
        Integer page = jsonObject.getInteger("page");
        Integer limit = jsonObject.getInteger("limit");
        String name = jsonObject.getString("name");
        String materialCode = jsonObject.getString("materialCode");
        String model = jsonObject.getString("model");
        String materialStatus = jsonObject.getString("materialStatus");
        String circulationState = jsonObject.getString("circulationState");
      String partSingleID= jsonObject.getString("partSingleID");
      String structureName= jsonObject.getString("structureName");
        name = (name != null) ? name : "";
        materialCode = (materialCode != null) ? materialCode : "";
        model = (model != null) ? model : "";
        materialStatus = (materialStatus != null) ? materialStatus : "";
        circulationState = (circulationState != null) ? circulationState : "";
        partSingleID = (partSingleID != null) ? partSingleID : "";
        structureName = (structureName != null) ? structureName : "";
        return componentSingleReportService.selectComponentSingleReport(limit, page,name,materialCode,model,materialStatus,circulationState,partSingleID,structureName);
    }

}
